//
//  AreaType.m
//  PacIsBack
//
//  Created by Simon André on 29/01/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "AreaType.h"
#import "BattleTeamProtocol.h"
#import "EnnemyTeam.h"
#import "CharacterProtocol.h"
#import "PlayerCharacter.h"
#import "CharacterFactory.h"

@implementation AreaType

@synthesize typeName, battleBackground, battleMusic;

-(NSString*) name{
	return [self typeName];
}

-(id) initWithDefaultValues{
	if (self = [super init]) {
		[self setTypeName:@"EarthRoad"];
		[self setBattleMusic:@"battle"];
		[self setBattleBackground:@"EarthRoad"];
	}
	return self;
}

-(id<BattleTeamProtocol>) ennemyEncounter:(NSInteger) level{
	NSMutableArray* ennemyCharacters = [[NSMutableArray alloc] init];
	if ((rand()%100)>15) {
		id<CharacterProtocol> character = [CharacterFactory createCharacterWithType:@"Mummy"];
		NSInteger i = 1;
		while (i<level) {
			[character gainLevel];
			i++;
		}
		[ennemyCharacters addObject:character];
	}
	else {
		id<CharacterProtocol> characterPharaoh = [CharacterFactory createCharacterWithType:@"Pharaoh"];
		NSInteger i = 1;
		while (i<level) {
			[characterPharaoh gainLevel];
			i++;
		}
		[ennemyCharacters addObject:characterPharaoh];
		id<CharacterProtocol> character = [CharacterFactory createCharacterWithType:@"Mummy"];
		i = 1;
		while (i<level) {
			[character gainLevel];
			i= i+3;
		}
		[ennemyCharacters addObject:character];
	}

	id<BattleTeamProtocol> ennemy = [[EnnemyTeam alloc] initWithCharacters:ennemyCharacters];
	[ennemyCharacters release];
	return [ennemy autorelease];
}

- (void) dealloc{
	[self setTypeName:nil];
	[self setBattleMusic:nil];
	[self setBattleBackground:nil];
	[super dealloc];
}

@end
